//
//  WFGuideCell.m
//  谷居
//
//  Created by dllo on 16/6/18.
//  Copyright © 2016年 刘万方. All rights reserved.
//

#import "WFGuideCell.h"
#import "Masonry.h"
#import "WFLabel.h"
#import "WFImageView.h"
#import "WFUIView.h"
#import "UIImageView+AFNetworking.h"
#import "WFHandleURL.h"
#define WS(weakSelf)  __weak __typeof(&*self)weakSelf = self
@interface WFGuideCell ()
@property (nonatomic, retain) WFImageView *likeImageView;

@property (nonatomic, retain) WFImageView *commentImageView;

@property (nonatomic, retain) WFLabel *titleLable;

@property (nonatomic, retain) WFLabel *likeLabel;

@property (nonatomic, retain) WFLabel *commentLabel;

@property (nonatomic, retain) WFLabel *typeLabel;

@property (nonatomic, retain) WFImageView *photoImageView;

@property (nonatomic, retain) WFUIView *backgroundVeiw;

@end
@implementation WFGuideCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCell];
    }
    return self;
}

- (void)createCell {
    
//    _backgroundVeiw = [WFUIView new];
//    [self.contentView addSubview:_backgroundVeiw];
//    [_backgroundVeiw release];
    
    _likeImageView = [[WFImageView alloc]init];
    [self.contentView addSubview:_likeImageView];
    [_likeImageView release];
    
    
    _commentImageView = [[WFImageView alloc]init];
    [self.contentView addSubview:_commentImageView];
    [_commentImageView release];
    
    _likeLabel = [[WFLabel alloc]init];
    [self.contentView addSubview:_likeLabel];
    [_likeLabel release];
    
    _commentLabel = [[WFLabel alloc]init];
    [self.contentView addSubview:_commentLabel];
    [_commentLabel release];
    
    
    _titleLable = [[WFLabel alloc]init];
    [self.contentView addSubview:_titleLable];
    [_titleLable release];
    
    
    _photoImageView = [[WFImageView alloc]init];
    [self.contentView addSubview:_photoImageView];
    [_photoImageView release];
    
    _typeLabel = [[WFLabel alloc]init];
    [self.contentView addSubview:_typeLabel];
    [_typeLabel release];
    
    
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [_photoImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).with.offset(10);
        make.bottom.equalTo(self.contentView).with.offset(-10);
        make.left.equalTo(self.contentView).offset(230);
        make.right.equalTo(self.contentView).offset(-10);

        
    }];
    NSString *url = [WFHandleURL getPicURL:_guideModel.covorPhotoId];
    [_photoImageView setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"placrholder-guide"]];
    
    
    
    [_titleLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        NSLog(@"更新约束");
        make.left.equalTo(self.contentView).offset(10);
        make.top.equalTo(self.contentView).offset(10);
        make.right.mas_equalTo(_photoImageView.mas_left).offset(-10);
        make.height.mas_equalTo(@50);
        _titleLable.text = _guideModel.title;
        _titleLable.numberOfLines = 2;
        
        _titleLable.font = [UIFont systemFontOfSize:17];

    }];
    
    [_typeLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.contentView).offset(10);
        make.size.mas_equalTo(CGSizeMake(60, 20));
        make.bottom.equalTo(self.contentView).offset(-10);
    }];
    _typeLabel.font = [UIFont systemFontOfSize:13];
    _typeLabel.text = _guideModel.categoryName;
    
    
    
    [_likeImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_typeLabel.mas_right).offset(10);
        make.centerY.and.height.equalTo(_typeLabel);
        make.width.mas_equalTo(20);
        
    }];
    _likeImageView.image = [UIImage imageNamed:@"喜欢1.png"];
    
    
    [_likeLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_likeImageView.mas_right).offset(10);
        make.centerY.and.height.equalTo(_likeImageView);
        make.width.mas_equalTo(30);
    }];
    _likeLabel.font = [UIFont systemFontOfSize:13];
    _likeLabel.text = [NSString stringWithFormat:@"%ld", _guideModel.likeCount];
    
    
    
    [_commentImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_likeLabel.mas_right).offset(10);
        make.centerY.and.height.equalTo(_likeLabel);
        make.width.equalTo(_likeImageView);
        
    }];
    
    _commentImageView.image = [UIImage imageNamed:@"评论.png"];
    
    [_commentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_commentImageView.mas_right).offset(10);
        make.size.and.centerY.equalTo(_likeLabel);
        
    }];
    _commentLabel.text = [NSString stringWithFormat:@"%ld", _guideModel.commentCount];
    _commentLabel.font = [UIFont systemFontOfSize:13];
}

- (void)dealloc {
    [super dealloc];
}
@end
